import api from '../../api';
import { message } from 'antd';
export default {
  namespace: 'OutSourcingOrderM',
  state: {},
  effects: {
    *queryAssetsInfo({ payload, callback }, { call, put }) {
      const res = yield call(api.outsourceInvestMsgMaintain.getDataById, payload);
      if (res && res.code == 0) {
        callback('success', res.data.dataSource);
      } else {
        callback('fail');
        message.error(`${res?.msg}`);
      }
    },
    //  委外投资 指令下达 type=1
    *orderSave({ payload, callback }, { call, put }) {
      callback('success');
    },
    // 委外投资 簿记指令下达
    *tradeBookSave({ payload, callback }, { call, put }) {
      const res = yield call(api.outsourceInvestMsgMaintain.tradeBookSave, payload);
      if (res && res.success) {
        message.success('簿记下达成功！');
        callback('success', res);
      } else {
        callback();
        message.error(`${res?.message || '簿记下达失败！'}`);
      }
    },
  },

  reducers: {
    save(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },
  },
};
